# coding=utf-8
import sys


# email配置
import smtplib
from email.mime.text import MIMEText

reload(sys)
sys.setdefaultencoding('utf-8')

mail_to_list = ["459798907@qq.com"]
mail_host = "smtp.qq.com"
mail_user = "18810295909@qq.com"
mail_pass = "loacrxscwzeccabe"



def send_mail(sub, content):
    me = "旅动足球" + "<" + mail_user + ">"
    msg = MIMEText(content, _subtype='plain', _charset='utf-8')
    msg['Subject'] = sub
    msg['From'] = me
    msg['To'] = ";".join(mail_to_list)
    try:
        server = smtplib.SMTP_SSL(mail_host, 465)
        # server.connect()
        server.login(mail_user, mail_pass)
        server.sendmail(me, mail_to_list, msg.as_string())
        server.close()
        return True
    except Exception, e:
        print(e.message)
        return False


if __name__ == "__main__":
    send_mail("test", "test")

